package cn.smxy.ln.controller;

import cn.smxy.ln.common.lang.Result;
import cn.smxy.ln.pojo.Department;
import cn.smxy.ln.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ln
 * @date 2022年05月24日 19:53
 */
@RestController
@RequestMapping("/department/consumer")
public class DepartmentController {

    @Autowired
    DepartmentService departmentService;

    @GetMapping("/list")
    public Result queryBycollegeId(@RequestParam(value = "collegeId", required = false) Long collegeId, @RequestParam(value = "name", required = false)  String name) {
        return Result.succ(departmentService.queryBycollegeId(collegeId, name));
    }

    @PostMapping("/save")
    public Result save(@RequestBody Department department) {
        return Result.succ(departmentService.save(department));
    }

    @PostMapping("/delete")
    public Result delete(@RequestParam(value = "id") Long id) {
        return Result.succ(departmentService.delete(id));
    }

    @PostMapping("/update")
    public Result update(@RequestBody Department department) {
        return Result.succ(departmentService.update(department));
    }
}
